var conf = 1; //控制服务    0：调用前端假数据   1：调用后台真实数据
var srvMap = (function(){

	var srcPref = ["","/flowdis/"];

    var dataArray = [
         {
            "query":srcPref[conf]+"query.json"
         },
         {
            "query":srcPref[conf]+"front/pc/pcprnca!query"
         }
    ];
    return {
        add: function(uid, mockSrc, srvSrc) {
            dataArray[0][uid] = srcPref[conf] + mockSrc;
            dataArray[1][uid] = srcPref[conf] + srvSrc;
        },
        get: function(uid) {
            return dataArray[conf][uid];
        },
		getName: function(url){
			var map = dataArray[conf];
			var name = null;
			for(var uid in map){
				if(map[uid] === url){
					name = uid;
					break;
				}
			}
			return name;
		},
        getAppPath:function(){
        	return srcPref[conf];
        },
        dataArrays:function(){
            return dataArray[conf];
        }
    };
})();
window.dataArray = srvMap.dataArrays();

/**
 * tpl 定义
 */
var tplMap = (function(){
    var version = '20131225';
    var tplPref = ["/aiscrm/pc/base/tpl/","page/"];
    var tpl = {
        // 办理路径
        "globalPath":tplPref[conf]+"globalPath.tpl"
    };

    // 为tpl添加版本号
    version = '?ver=' + version;
    for(var perTpl in tpl){
        if(tpl.hasOwnProperty(perTpl)){
        	var tplPath = tpl[perTpl];
        	tplPath = (conf===1)?tplPath.replace(".tpl","_tpl"):tplPath;
            tpl[perTpl] = tplPath+version;
        }
    }

    return {
        add: function(uid,tplSrc) {
            if(1 === conf){
                tplSrc = tplSrc.replace(".tpl","_tpl");
            }
            tpl[uid] = tplPref[conf] + tplSrc + version;
        },
        get: function(uid) {
            return tpl[uid];
        },
        tpls: function() {
            return tpl;
        }
    };
})();
window.tpl = tplMap.tpls();

//屏蔽生产环境log
(function(){
	if(window.location.hostname.indexOf('localhost') === -1){
		window.console.log = function(){};
	}
})();
